package se.cefalo.ceti.gui.controllers;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import se.cefalo.ceti.domain.User;
import se.cefalo.ceti.persistance.UserDao;

/**
 * Created by IntelliJ IDEA.
 * User: kopo700
 * Date: Oct 31, 2006
 * Time: 1:02:06 PM
 * To change this template use File | Settings | File Templates.
 */
public class CreateUserController extends SimpleFormController {


    public CreateUserController() {
        setCommandName("user");
        setCommandClass(User.class);
    }


    protected ModelAndView onSubmit(Object command, BindException errors) throws Exception {

        User user = (User) command;

        getUserDao().createUser(user);

        return super.onSubmit(command, errors);
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    UserDao userDao;

}
